<template>
  <div>
    <div class='father'>
      <p style='text-align: left;'> <img :src="'./static/image/gold2.png'" alt=""></p>
      <p>当前：{{Math.floor(progress1*100)}}/10000</p>
      <div class='son'>
        <div ref='sunziiG' class='sunzi gold'>
          <p>当前{{parseInt(progress1*100)/100}}%</p>
        </div>
      </div>
    </div>
    <div class="borderStyle" style="display: none;">
      <div class="top">
        <div class="weizhi">
          <div class="move">
            <img src="../../static/image/move.png" alt="">
          </div>
          <div class="qi">
            <img src="../../static/image/qi.png" alt="">
          </div>
          <div class="choangzi">
            <img src="../../static/image/chongzi.png" alt="">
          </div>
        </div>
        <p>当前无开启的活动</p>
      </div>
      <div class="fontStyle">
        <img :src="'../../static/image/'+img[status]" alt="">
      </div>
    </div>
    <div class='father' style="top: 270px;">
      <p style='text-align: left;'> <img :src="'./static/image/gold3.png'" alt=""></p>
      <p>当前：{{Math.floor(progress2*100)}}/10000</p>
      <div class='son'>
        <div ref='sunziiS' class='sunzi ying'>
          <p>当前{{parseInt(progress2*100)/100}}%</p>
        </div>
      </div>
    </div>
    <div class="borderStyle" style="display: none;top: 310px;">
      <div class="top">
        <div class="weizhi">
          <div class="move">
            <img src="../../static/image/move.png" alt="">
          </div>
          <div class="qi">
            <img src="../../static/image/qi.png" alt="">
          </div>
          <div class="choangzi">
            <img src="../../static/image/chongzi.png" alt="">
          </div>
        </div>
        <p>当前无开启的活动</p>
      </div>
      <div class="fontStyle">
        <img :src="'../../static/image/'+img[status]" alt="">
      </div>
    </div>
    <div class='father' style="top: 390px;">
      <p style='text-align: left;'> <img :src="'./static/image/gold4.png'" alt=""></p>
      <p>当前：{{Math.floor(progress3*100)}}/10000</p>
      <div class='son'>
        <div ref='sunziiC' class='sunzi tong'>
          <p>当前{{parseInt(progress3*100)/100}}%</p>
        </div>
      </div>
    </div>
    <div class="borderStyle" style="display: none;top: 430px;">
      <div class="top">
        <div class="weizhi">
          <div class="move">
            <img src="../../static/image/move.png" alt="">
          </div>
          <div class="qi">
            <img src="../../static/image/qi.png" alt="">
          </div>
          <div class="choangzi">
            <img src="../../static/image/chongzi.png" alt="">
          </div>
        </div>
        <p>当前无开启的活动</p>
      </div>
      <div class="fontStyle">
        <img :src="'../../static/image/'+img[status]" alt="">
      </div>
    </div>
  </div>
</template>

<script>
import $ from "jquery";
import { setTimeout } from "timers";
export default {
  data() {
    return {
      progress1: 0,
      progress2: 0,
      progress3: 0,
      status: parseInt(u.getStore("status")),
      img: ["nohuodong.png", "bdFont.png", "", "end.png"]
    };
  },
  methods: {
    /*bar() {
      this.$refs.sunzii.style.width = "100%";
    }*/
  },
  created() {
    let time = setInterval(() => {
      if (u.flag) {
        clearInterval(time);
        u.progress({cointype:localStorage.getItem('cointype')},data=>{
          console.log(data)
          if (data &&data[0].code == "200"){
            let arr=data[0].data;
            for(let i=0;i<arr.length;i++){
              if(arr[i].keyname=="gold" && arr[i].status==2){
                $(".father").eq(0).css("display","block");
                $(".borderStyle").eq(0).css("display","none");
                let progress1 = arr[i].count;
                this.$refs.sunziiG.style.width = progress1 / 106.1 + "%";
                let timmer = setInterval(() => {
                  this.progress1++;
                  if (this.progress1 >= progress1/100) {
                    this.progress1 = progress1/100;
                    clearInterval(timmer);
                  }
                }, 20);
              }else if(arr[i].keyname=="gold" && arr[i].status!=2){
                $(".father").eq(0).css("display","none");
                $(".borderStyle").eq(0).css("display","block");
              }else if(arr[i].keyname=="silver" && arr[i].status==2){
                $(".father").eq(1).css("display","block");
                $(".borderStyle").eq(1).css("display","none");
                let progress2 = arr[i].count;
                this.$refs.sunziiS.style.width = progress2 / 106.1 + "%";
                let timmer = setInterval(() => {
                  this.progress2++;
                  if (this.progress2 >= progress2/100) {
                    this.progress2 = progress2/100;
                    clearInterval(timmer);
                  }
                }, 20);
              }else if(arr[i].keyname=="silver" && arr[i].status!=2){
                $(".father").eq(1).css("display","none");
                $(".borderStyle").eq(1).css("display","block");
              }else if(arr[i].keyname=="copper" && arr[i].status==2){
                $(".father").eq(2).css("display","block");
                $(".borderStyle").eq(2).css("display","none");
                let progress3 = arr[i].count;
                this.$refs.sunziiC.style.width = progress3 / 106.1 + "%";
                let timmer = setInterval(() => {
                  this.progress3++;
                  if (this.progress3 >= progress3/100) {
                    this.progress3 = progress3/100;
                    clearInterval(timmer);
                  }
                }, 20);
              }else if(arr[i].keyname=="copper" && arr[i].status!=2){
                $(".father").eq(2).css("display","none");
                $(".borderStyle").eq(2).css("display","block");
              }
            }
          }
        })
       /* u.findActivityPercent({ cointype: localStorage.getItem('cointype') }, data => {
          if (data && data[0].code == "200") {
            let progress =  parseInt(data[0].data);
            this.$refs.sunzii.style.width =  progress / 1.061 + "%";
            let timmer = setInterval(() => {
              if (this.progress >= progress) {
                if (this.progress == 100) {
                  this.$parent.pop_index = false;
                }
                this.progress = data[0].data;
                clearInterval(timmer);
                return;
              }
              this.progress++;
            }, 30);
          }
        });*/
      }
    }, 500);
  },
  mounted() {}
};
</script>

<style scoped lang='less'>
.content {
  // height: 100vh;
  // width: 100vw;
  // background: url(../../static/image/ginsengbg2.png) no-repeat center center;
  // background-size: cover;
}
.father {
  height: 100px;
  width: 300px;
  position: absolute;
  top: 150px;
  left: 18px;
  padding: 12px;
  box-sizing: border-box;
  .son {
    width: 100%;
    height: 70px;
    background: url(../../static/image/barbg.png) no-repeat center;
    background-size: 100% 100%;
    .sunzi {
      position: relative;
      left: 8px;
      width: 0;
      background-size: 98% 58%;
      background-position-x: -10px;
      transition: width 2s;
      line-height: 70px;
      text-align: center;
      color: white;
      height: 34px;
      top: 18px;
      border-radius: 12px;
      // overflow: hidden;
      p {
        width: 300px;
        box-sizing: border-box;
        padding-left: 80px;
        text-align: left;
        top: -19px;
        position: relative;
      }
    }
    .gold {
      background: url(../../static/image/goldProgress.png) no-repeat center;
      background-size: 160% 200%;
    }
    .ying {
      background: url(../../static/image/yingProgress.png) no-repeat center;
      background-size: 160% 200%;
      text-shadow: 1px 1px 1px rgba(197, 197, 197, 0.75),
        1px -1px 1px rgba(197, 197, 197, 0.75);
    }
    .tong {
      background: url(../../static/image/tongProgress.png) no-repeat center;
      background-size: 160% 200%;
      text-shadow: 1px 1px 1px rgba(255, 137, 68, 0.75),
        1px -1px 1px rgba(255, 137, 68, 0.75);
    }
  }

  p {
    font-size: 16px;
    color: white;
    padding-left: 10px;
    text-shadow: 0 2px #3a230a, -1px 0 #3a230a, -2px 2px #3a230a,
      -2px 1px #3a230a;
    text-align: center;
  }
}

.borderStyle {
  width: 270px;
  height: 150px;
  padding-top: 25px;
  margin: auto;
  position: absolute;
  top: 190px;
  left: 30px;
  .top {
    margin-bottom: 69px;
    .weizhi{
      height: 16px;
      background: url("../../static/image/bdBorder.png") no-repeat;
      background-size: 100% 100%;
      position: relative;
      .move {
        position: absolute;
        height: 14px;
        line-height: 14px;
        img {
          width: 60%;
          height: 14px;
        }
      }
      .qi {
        position: absolute;
        left: 260px;
        top: -33px;
      }
      .choangzi {
        position: absolute;
        top: -40px;
        left: 90px;
      }
    }
    p{
      margin-top: 10px;
      font-size: 16px;
      color: white;
      padding-left: 10px;
      text-shadow: -2px 1px 1px rgba(137, 64, 0, 0.75),
      2px -1px 1px rgba(137, 64, 0, 0.75);
      text-align: center;
    }
  }
  .fontStyle {
    text-align: center;
  }
}
</style>
